<!--
  To change this template, choose Tools | Templates
  and open the template in the editor.
-->

<%@ page import="baratopradedeu.Cupom" %>

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta name="layout" content="main" />
  <g:set var="entityName" value="${message(code: 'cupom.label', default: 'Cupom')}" />
  <title><g:message code="default.create.label" args="[entityName]" /></title>
</head>
</head>
<body>
  <div class="body">
    <h1><g:message code="default.create.label" args="[entityName]" /></h1>
    <h2>Gerando cupom. Aguarde...</h2>
    <g:if test="${flash.message}">
      <div class="message">${flash.message}</div>
    </g:if>
    <g:hasErrors bean="${cupomInstance}">
      <div class="errors">
        <g:renderErrors bean="${cupomInstance}" as="list" />
      </div>
    </g:hasErrors>


    <g:form action="gerarCupom">
      <g:hiddenField name="cupomId" value="${cupomId}" />
	  <g:hiddenField name="pedido.id" value="${cupomInstance?.pedido?.id}" />
 
      <div class="dialog">
        <table>
                        <tbody>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="cliente"><g:message code="cupom.cliente.label" default="Cliente" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: cupomInstance, field: 'cliente', 'errors')}">
                                    <g:select name="cliente.id" from="${baratopradedeu.Cliente.list()}" optionKey="id" value="${cupomInstance?.cliente?.id}"  />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="dataCompra"><g:message code="cupom.dataCompra.label" default="Data Compra" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: cupomInstance, field: 'dataCompra', 'errors')}">
                                    <g:datePicker name="dataCompra" precision="day" value="${cupomInstance?.dataCompra}"  />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="dataValidade"><g:message code="cupom.dataValidade.label" default="Data Validade" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: cupomInstance, field: 'dataValidade', 'errors')}">
                                    <g:datePicker name="dataValidade" precision="day" value="${cupomInstance?.dataValidade}"  />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="oferta"><g:message code="cupom.oferta.label" default="Oferta" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: cupomInstance, field: 'oferta', 'errors')}">
                                    <g:select name="oferta.id" from="${baratopradedeu.Oferta.list()}" optionKey="id" value="${cupomInstance?.oferta?.id}"  />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="pedido"><g:message code="cupom.pedido.label" default="Pedido" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: cupomInstance, field: 'pedido', 'errors')}">
                                    <g:select name="pedido.id" from="${baratopradedeu.Pedido.list()}" optionKey="id" value="${cupomInstance?.pedido?.id}"  />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="statusCupom"><g:message code="cupom.statusCupom.label" default="Status Cupom" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: cupomInstance, field: 'statusCupom', 'errors')}">
                                    <g:checkBox name="statusCupom" value="${cupomInstance?.statusCupom}" />
                                </td>
                            </tr>
                        
                        </tbody>
                    </table>         
      </div>

      <div class="buttons">
        <span class="button">
          <g:submitButton name="create" class="save"
                          value="${message(code: 'default.button.create.label', default: 'Gerar cupom')}" />
          <g:link class="create" controller="cupom" action="salvarCupom" params="[cupomId:cupomInstance.id]">Cupom</g:link>
        </span>
      </div>
    </g:form>
  </div>
</body>
</html>
